package no.kolstad.moviesdatabase.moviesdatabase.core.model;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.appfuse.model.BaseObject;

/**
 * Copyright [2008] [Christopher] Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and limitations under the License. 
 * @author Christopher
 */
@Entity
public class Movie extends BaseObject implements Serializable {
  
    private Long id;
    private String title;
    private Long prodYear;
    private Borrower borrower;

  @ManyToOne
  public Borrower getBorrower() {
    return borrower;
  }

  public void setBorrower(Borrower borrower) {
    this.borrower = borrower;
  }

  @Id @GeneratedValue
  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public Long getProdYear() {
    return prodYear;
  }

  public void setProdYear(Long prodYear) {
    this.prodYear = prodYear;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  @Override
  public String toString() {
    return new ToStringBuilder(this)
        .append("[ID]")
        .append(id)
        .append("[ProdYear]") 
        .append(prodYear)
        .append("[Title]")
        .append(title)
        .toString();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Movie other = (Movie) obj;
    if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
      return false;
    }
    if (this.title != other.title && (this.title == null || !this.title.equals(other.title))) {
      return false;
    }
    if (this.prodYear != other.prodYear && (this.prodYear == null || !this.prodYear.equals(other.prodYear))) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash = 17 * hash + (this.id != null ? this.id.hashCode() : 0);
    hash = 17 * hash + (this.title != null ? this.title.hashCode() : 0);
    hash = 17 * hash + (this.prodYear != null ? this.prodYear.hashCode() : 0);
    return hash;
  }

  

}
